<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body style="height: 300px">
<script type="text/javascript">

    tttt = {
        whichled : 1,
        file_name : ""
    };

    scope.click = function (button) {
        tttt.whichled = document.getElementById("which_led2").value - '0';
        button.msg.payload = tttt;
        button.send(button.msg);
    }

    function previewFile() {
        var preview = document.querySelector('img');
        var file = document.querySelector('input[type=file]').files[0];
        var reader = new FileReader();

        reader.onloadend = function () {
            preview.src = reader.result;
            tttt.file_name=file.name;
        }
        if (file) {
            reader.readAsDataURL(file);

        } else {
            preview.src = "";
        }
    }

</script>
<div>
    <select id="which_led2">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
    </select>
</div>
<div style="height: 250px">
    <input type="file" onchange="previewFile()"><br>
    <img src="" height="200" width="300" alt="Image preview..."/>
    <md-button name="submit" id="submit2" style="width: 50px;height: 50px;background-color: cadetblue"
               ng-model="msg.payload" ng-click="click(this)">上传
    </md-button>
</div>

</body>
</html>